package 动态规划;

import java.util.Arrays;

/**
 * @author tmh
 * @date 2024/12/16 21:02
 * @description
 */
public class T300最长递增子序列 {
    public static int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);
        //result 来保存最大的值
        int result = 0;
        //开始进行比较
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[j] + 1, dp[i]);
                }
            }
            result = Math.max(result, dp[i]);
        }
        return result;
    }
}
